package com.bw.lib_base.view

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.blankj.utilcode.util.ToastUtils

/**
 * 基础的Activity
 */

open abstract class BaseActivity <VDB:ViewDataBinding> :AppCompatActivity(){

    protected lateinit var mDataBinding: VDB


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //获取布局绑定代理对象
        mDataBinding=DataBindingUtil.setContentView(this, getLayoutId())
        //初始化
        initView()
    }

    protected open fun initView(){

    }

    protected fun showToast(msg:String){
        if(!msg.isNullOrEmpty()){
            ToastUtils.showLong(msg)
        }
    }

    protected abstract fun getLayoutId(): Int
}